package com.acmedcare.aclauncher;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.acmedcare.aclauncher.storage.DaoSession;
import com.acmedcare.aclauncher.storage.table.ContactColumn;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "CONTACT_COLUMN".
*/
public class ContactColumnDao extends AbstractDao<ContactColumn, Long> {

    public static final String TABLENAME = "CONTACT_COLUMN";

    /**
     * Properties of entity ContactColumn.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Userid = new Property(1, String.class, "userid", false, "USERID");
        public final static Property Username = new Property(2, String.class, "username", false, "USERNAME");
        public final static Property Token = new Property(3, String.class, "token", false, "TOKEN");
        public final static Property Type = new Property(4, String.class, "type", false, "TYPE");
        public final static Property Gender = new Property(5, String.class, "gender", false, "GENDER");
        public final static Property Remark = new Property(6, String.class, "remark", false, "REMARK");
        public final static Property Signifo = new Property(7, String.class, "signifo", false, "SIGNIFO");
        public final static Property Location = new Property(8, String.class, "location", false, "LOCATION");
        public final static Property Loginname = new Property(9, String.class, "loginname", false, "LOGINNAME");
        public final static Property Avatar = new Property(10, String.class, "avatar", false, "AVATAR");
        public final static Property Phone = new Property(11, String.class, "phone", false, "PHONE");
    }


    public ContactColumnDao(DaoConfig config) {
        super(config);
    }
    
    public ContactColumnDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"CONTACT_COLUMN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"USERID\" TEXT," + // 1: userid
                "\"USERNAME\" TEXT," + // 2: username
                "\"TOKEN\" TEXT," + // 3: token
                "\"TYPE\" TEXT," + // 4: type
                "\"GENDER\" TEXT," + // 5: gender
                "\"REMARK\" TEXT," + // 6: remark
                "\"SIGNIFO\" TEXT," + // 7: signifo
                "\"LOCATION\" TEXT," + // 8: location
                "\"LOGINNAME\" TEXT," + // 9: loginname
                "\"AVATAR\" TEXT," + // 10: avatar
                "\"PHONE\" TEXT);"); // 11: phone
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CONTACT_COLUMN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, ContactColumn entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(2, userid);
        }
 
        String username = entity.getUsername();
        if (username != null) {
            stmt.bindString(3, username);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(4, token);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(5, type);
        }
 
        String gender = entity.getGender();
        if (gender != null) {
            stmt.bindString(6, gender);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(7, remark);
        }
 
        String signifo = entity.getSignifo();
        if (signifo != null) {
            stmt.bindString(8, signifo);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(9, location);
        }
 
        String loginname = entity.getLoginname();
        if (loginname != null) {
            stmt.bindString(10, loginname);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(11, avatar);
        }
 
        String phone = entity.getPhone();
        if (phone != null) {
            stmt.bindString(12, phone);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ContactColumn entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(2, userid);
        }
 
        String username = entity.getUsername();
        if (username != null) {
            stmt.bindString(3, username);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(4, token);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(5, type);
        }
 
        String gender = entity.getGender();
        if (gender != null) {
            stmt.bindString(6, gender);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(7, remark);
        }
 
        String signifo = entity.getSignifo();
        if (signifo != null) {
            stmt.bindString(8, signifo);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(9, location);
        }
 
        String loginname = entity.getLoginname();
        if (loginname != null) {
            stmt.bindString(10, loginname);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(11, avatar);
        }
 
        String phone = entity.getPhone();
        if (phone != null) {
            stmt.bindString(12, phone);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public ContactColumn readEntity(Cursor cursor, int offset) {
        ContactColumn entity = new ContactColumn( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userid
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // username
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // token
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // type
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // gender
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // remark
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // signifo
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // location
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // loginname
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // avatar
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11) // phone
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ContactColumn entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setUserid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setUsername(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setToken(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setGender(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setRemark(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setSignifo(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setLocation(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setLoginname(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setAvatar(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setPhone(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ContactColumn entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ContactColumn entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(ContactColumn entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
